// https://leetcode.cn/problems/fizz-buzz/
// Created by ade on 2022/8/5.
//
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution {
public:
    int thirdMax(vector<int>& nums) {
        sort(nums.rbegin(), nums.rend());
        int len = nums.size();
        if(len <= 2) return nums[0];
        int maxNum = nums[0];
        int count = 1;
        for(int i = 1; i < nums.size(); i++){
            if(nums[i] < nums[i-1]){
                maxNum = nums[i];
                count++;
                if(count == 3){
                    return maxNum;
                }
            }
        }
        return nums[0];
    }
};

int main(){
    Solution so;

}